let videoAd = null
var t = getApp(), a = null;
// 在页面中定义插屏广告
let interstitialAd = null

Page({
    data: {
        ad: {},
        isTiptrue: !0,
        test:0,
        jiliShow:false
    },
    jili(){
      let that = this
      console.log(videoAd)
      if (videoAd) {
        videoAd.show()
          .then(() => {
            that.resetTime()
          })
          .catch(() => {
            // 失败重试
            videoAd.load()
              .then(() => videoAd.show().then(() => {
                that.resetTime()
              }))
              .catch(err => {
                console.log('激励视频 广告显示失败')
              })
          })
      }
    },
    test(){
        t.globalData.test == 1&&wx.navigateTo({
          url: '/pages/test/test',
        })
    },
    load(e){
        console.log(e)
    },
    error(e){
        console.log(e)
    },
    onShow(){
        this.getRandomAd()
        getApp().chaping()
    },
    onLoad: function() {
        var e = this;
        let that = this
      // setTimeout(function(){
      //   if (getApp().globalData.adTest.length > 0 && wx.createRewardedVideoAd) {
      //     that.setData({
      //       jiliShow:true
      //     })
      //     videoAd = wx.createRewardedVideoAd({
      //       adUnitId: getApp().globalData.adTest.filter(item => {
      //         return item.type == 'jili'
      //       })[0].id
      //     })
      //     videoAd.onLoad(() => { })
      //     videoAd.onError((err) => { })
      //     videoAd.onClose((res) => { })
      //   }
      // },1000)
        getApp().getRandomAd(true,this)
        console.log(this)
        setTimeout(function(){
            e.getRandomAd()
            e.getRandomAd(true)
            getApp().chaping()
        },500)
        
        var i = wx.getStorageSync("loadOpen");
        void 0 == i || "" == i ? this.setData({
            isTiptrue: !0
        }) : this.setData({
            isTiptrue: !1
        });
    },
    onShareTimeline(){
        return {title:'史上最好用的修图，表情制作，图片制作工具'}
    },
    onShareAppMessage: function() {
        return {
            title: "超好用的图片编辑小程序",
            path: "pages/index/index",
            imageUrl: "/image/maskshareimg.jpg"
        };
    },
    closeGuide: function(t) {
        wx.setStorage({
            key: "loadOpen",
            data: "OpenTwo"
        }), this.setData({
            isTiptrue: !1
        });
    }
});